import yagmail,pytest,os,logging

# 生成日志
def log():

    logging.basicConfig(
        level=logging.DEBUG,
        filename='./Log/A3mall.log',
        format='%(name)s %(message)s %(asctime)s %(thread)d',
        filemode='a+'
    )

def email(filename):

    email = yagmail.SMTP(user='3516922232@qq.com',password='sauvhzrimccccjbi',host='smtp.qq.com')
    email.send(to='3516922232@qq.com',subject='A3mall接口测试',contents=['auto框架部署'],attachments=filename)
    email.close()

def report_html(script):
    """生成HTML报告"""
    pytest.main([script, '-s', '--html=./Report/baogao.html'])

def report_allure(script):
    """生成Allure报告"""
    # 清理并生成新的Allure结果数据
    pytest.main([script, '--clean-alluredir', '--alluredir', './temp'])
    # 生成Allure报告
    os.system('allure generate ./temp -o ./allure-report --clean')